package com.kcwl.carrier.infrastructure.repository.persostence;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.kcwl.carrier.domain.repository.ICarrierDriverRepository;
import com.kcwl.carrier.infrastructure.enums.CarrierInfoEnums;
import com.kcwl.carrier.infrastructure.repository.mapper.CarrierDriverMapper;
import com.kcwl.carrier.infrastructure.repository.po.CarrierDriverPO;
import com.kcwl.ddd.domain.repository.BaseRepositoryImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lxp
 * @date 2023/1/10 11:24
 * @Description
 */
@Service
public class CarrierDriverRepositoryImpl extends BaseRepositoryImpl<CarrierDriverMapper, CarrierDriverPO> implements ICarrierDriverRepository {

    @Resource
    CarrierDriverMapper carrierDriverMapper;

    @Override
    public List<CarrierDriverPO> queryCarrierDriverListByUserId(Long userId) {
        Assert.notNull(userId,"userId 不能为空");
        LambdaQueryWrapper<CarrierDriverPO> wrapper = new LambdaQueryWrapper();
        wrapper.eq(CarrierDriverPO::getUserId,userId);
        wrapper.eq(CarrierDriverPO::getIsDel, CarrierInfoEnums.NO.getCode());
        return this.carrierDriverMapper.selectList(wrapper);
    }
}
